#pragma once
#include<iostream>
#include"RBTree.h"
using namespace std;

template<class k,class v>
class mymap {
	struct MapKeyOfT {
		const k& operator()(const pair<k, v> & data) {
			return data.first;
		}
	};
public:
	typedef typename RBTree<k, pair<const k, v>, MapKeyOfT>::Iterator iterator;
	typedef typename RBTree<k, pair<const k, v>, MapKeyOfT>::const_Iterator constiterator;

	pair<iterator, bool> Insert(pair<k, v> data) {
		return _t.Insert(data);
	}
	iterator end() {
		return _t.end();
	}
	iterator begin() {
		return _t.begin();
	}
	constiterator begin() const{
		return _t.begin();
	}
	constiterator end() const {
		return _t.end();
	}

	v& operator[](const k& _k) {
		pair<iterator, bool> ret = Insert(make_pair(_k, v()));
		return ret.first->second;
	}
	void print() {
		_t.InOrder();
	}
private:
	RBTree<k, pair<const k, v>, MapKeyOfT> _t;
};